<?php
header('Content-type:text/html;charset=utf-8');
/*正99*/
//for($i=1;$i<=9;$i++):
//    for($j=1;$j<=$i;$j++):
//        echo "$j*$i=".$j*$i."&nbsp;&nbsp;";
//        endfor;
//    echo "<br/>";
//endfor;
/*反99*/
//for($a=9;$a<=9;$a--):
//    for($b=1;$b<=$a;$b++):
//        echo "$b*$a=".$b*$a."&nbsp&nbsp";
//    endfor;
//    echo "<br/>";
//endfor;
/*for while do-while循环*/
//$sum=0;
//$i=1;
//for($i;$i<=100;$i++):
//    $sum+=$i;
//endfor;
//echo $sum;
//echo "<br/>";
//while($i<=100):
//    $sum+=$i;
//    $i++;
//endwhile;
//echo $sum;
//echo "<br/>";
//do{
//    $sum+=$i;
//    $i++;
//}while($i<=100);
//echo $sum;
if(!empty($_POST['btn'])):
    if(empty($_POST['hobby'])):
        echo 'b';
    else:
    echo "我的爱好有";
    foreach ($_POST['hobby'] as $val) {
        echo $val.",";
    }
    endif;
endif;
?>
<form method="post" action="" >
    爱好：
    <input type="checkbox" name="hobby[]" value='爬山'>爬山
    <input type="checkbox" name="hobby[]" value='游泳'>游泳
    <input type="checkbox" name="hobby[]" value='看书'>看书
    <input type="checkbox" name="hobby[]" value='睡觉'>睡觉<br/>
    <input type="submit" name="btn" value="提交">
</form>


